using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using System;

public class GameManager : Singleton<GameManager>
{
    public CharacterStats playerStats;
    public GameObject player,body;

    public event Action<Vector3> OnPlayerDeath;

    //public event Action OnPickUp;

    public void RigisterPlayer(GameObject p)
    {
        player = p;
        playerStats = p.GetComponent<CharacterStats>();
    }


    private void Start()
    {
        //
    }

    private void Update()
    {
        
        //if playerDeath happens
        if(playerStats.CurrentHealth==0)
        {
            //Get all body objs/use braodcast
            Vector3 pos = player.transform.position;
            Quaternion rot = player.transform.rotation;
            OnPlayerDeath?.Invoke(player.transform.position);
            Instantiate(body,pos,rot);
            //if body.lastness==0 Destroy(body.gameObject)
            //create new body at where death happens
            //respawn player at (nearest) respawn point


        }


    }
}
